home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG Revelations
/
BMUG Revelations.toast
/
Utilities
/
Random
/
Commodore 64c
/
SOURCE
/
Menus.c
< prev
next >
Wrap
Text File
|
1994-03-19
|
5KB
|
263 lines
/*
Commodore 64 Emulator v0.2 Earle F. Philhower III
Copyright (C) 1993-4 (st916w9r@dunx1.ocs.drexel.edu)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Menus.h"
#include "Error.h"
#define kAboutDialog 131
Handle menuBar;
MenuHandle appleMenu, fileMenu, editMenu, deviceMenu, testMenu;
int MenuInitialize()
{
menuBar=GetNewMBar(128);
if (menuBar==nil) return kMissingResource;
SetMenuBar(menuBar);
appleMenu=GetMenu(kAppleMenu);
if (appleMenu==nil) return kMissingResource;
AddResMenu(appleMenu, 'DRVR');
fileMenu=GetMenu(kFileMenu);
if (fileMenu==nil) return kMissingResource;
editMenu=GetMenu(kEditMenu);
if (editMenu==nil) return kMissingResource;
deviceMenu=GetMenu(kDeviceMenu);
if (deviceMenu==nil) return kMissingResource;
testMenu=GetMenu(kTestMenu);
if (testMenu==nil) return kMissingResource;
DisableItem(editMenu, 1);
DrawMenuBar();
}
void DoMenuChoice(long menuChoice)
{
int theMenu, theItem;
if (menuChoice==0)
{
HiliteMenu(0);
return;
}
theMenu=HiWord(menuChoice);
theItem=LoWord(menuChoice);
HiliteMenu(theMenu);
switch(theMenu)
{
case kAppleMenu:
DoAppleMenu(theItem);
break;
case kFileMenu:
DoFileMenu(theItem);
break;
case kEditMenu:
DoEditMenu(theItem);
break;
case kDeviceMenu:
DoDeviceMenu(theItem);
break;
case kTestMenu:
DoTestMenu(theItem);
break;
}
HiliteMenu(0);
}
void DoAppleMenu(int theItem)
{
EventRecord event;
Str255 daName;
DialogPtr dialog;
int done;
switch (theItem)
{
case kAbout:
/* Draw About window */
dialog=GetNewDialog(kAboutDialog, nil, (WindowPtr)-1L);
ShowWindow(dialog);
DrawDialog(dialog);
/* Handle events until time to drop window */
done=0;
while (!done) {
FlushEvents(0,-1);
WaitNextEvent(everyEvent, &event, 60L, nil);
switch(event.what)
{
/* On keypress or buttonpress stop waiting */
case mouseDown: done=1; break;
case autoKey: done=1; break;
case keyDown: done=1; break;
/* *Must* tell event manager we're "updating" */
case updateEvt:
BeginUpdate((WindowPtr)event.message);
EndUpdate((WindowPtr)event.message); break;
}
}
/* Drop window and redraw the VIC screen */
HideWindow(dialog);
DisposDialog(dialog);
TotalRedrawVIC();
break;
default:
/* Run the selected Desk Accessory */
GetItem(appleMenu, theItem, daName);
OpenDeskAcc(daName);
break;
}
}
void DoFileMenu(int theItem)
{
switch(theItem)
{
case kOpenRAM:
LoadRAM();
break;
case kSaveRAM:
SaveRAM();
break;
case kReset:
/* Clear the menu hilite, since we're gonna be away a while */
HiliteMenu(0);
/* Reset PC, memory map */
RegisterInitialize();
/* Go compute */
ProcessorLoop();
break;
case kPageSetup:
break;
case kPrint:
break;
case kPrefs:
break;
case kQuit:
CleanUpCommodore();
ExitToShell();
break;
}
}
void DoEditMenu(int theItem)
{
switch(theItem)
{
case kUndo:
break;
case kCut:
break;
case kCopy:
break;
case kPaste:
break;
case kClear:
break;
}
}
void DoDeviceMenu(int theItem)
{
switch(theItem)
{
case kCreateImage:
FloppyCreateImage();
break;
case kSelectImage:
FloppySelectImage();
break;
case kDirectory:
FloppyDirectory();
break;
case kCopyTo:
FloppyCopyTo();
break;
case kCopyFrom:
FloppyCopyFrom();
break;
case kChdir:
HardChangeDirectory();
break;
case kNewPFile:
PrinterNewFile();
break;
case kAppendPFile:
PrinterAppendFile();
break;
case kXvert:
PrinterXvertCharacters();
break;
case kDisplayPFile:
PrinterDisplayFile();
break;
case kLoadTape:
LoadTape();
break;
}
}
void DoTestMenu(int theItem)
{
switch(theItem)
{
case kTest68k:
Test68k();
break;
case kTestVIC:
break;
}
}